#include <iostream>
#include <vector>
#include <cstdlib>
#include <ctime>
#include <math.h>
#include <algorithm>
#include <map>
using namespace std;

bool isValidSudoku(vector<vector<char>>& board) {
    map<char,short>row;
    vector<map<char,short>>columns(9,map<char,short>());
    vector<map<char,short>>boxs(9,map<char,short>());
    short boxIndex;
    for(short i=0;i<9;i++){
        row.clear();
        for(short j=0;j<9;j++){
            if(board[i][j]!='.'){
                if(row.find(board[i][j])==row.end()&&
                   columns[j].find(board[i][j])==columns[j].end()){
                    row[board[i][j]]=1;
                    columns[j][board[i][j]]=1;
                }
                else return false;
                boxIndex=(i/3)*3+(j/3);
                if(boxs[boxIndex].find(board[i][j])==boxs[boxIndex].end()){
                    boxs[boxIndex][board[i][j]]=1;
                }else return false;
            }
        }
    }
    return true;
}
int main(){
    vector<vector<char>>a={{'5','3','.','.','7','.','.','.','.'},
                           {'6','.','.','1','9','5','.','.','.'},
                            {'.','9','8','.','.','.','.','6','.'},
                            {'8','.','.','.','6','.','.','.','3'},
                            {'4','.','.','8','.','3','.','.','1'},
                            {'7','.','.','.','2','.','.','.','6'},
                            {'.','6','.','.','.','.','2','8','.'},
                            {'.','.','.','4','1','9','.','.','5'},
                            {'.','.','.','.','8','.','.','7','9'}};

    cout<<isValidSudoku(a);
    return 0;
}